<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>二分查找</title>
  <script type="text/javascript">
    var arr = [1,4,8,10,13,14,19,24];
    binarySearch(19,arr,0,arr.length-1);
    function binarySearch(key,array,low,high)
	  {
        var mid=Math.round((low+high)/2);
        if(low>high)
		{
            document.write('don\'t,find');
            return;
        }
        if(key>array[mid])
		{
            binarySearch(key,array,mid+1,high);
        }
        else if(key<array[mid])
		{
            binarySearch(key,array,low,mid-1);
        }
        else
		{
            document.write("查找元素的下标为： "+mid);
        }
    }
  </script>
 </head>
 <body> 
 </body>
</html>
